<template>
  <!-- 二维码组件 -->
  <canvas ref="qrcode"></canvas>
</template>

<script setup>
import { ref, onMounted, defineProps } from 'vue'
import QRCode from 'qrcode'
const props = defineProps({
  value: {
    type: String,
    default: "https://baidu.com"
  }
})

const qrcode = ref(null)

onMounted(() => {
  render()
})

const render = () => {
  QRCode.toCanvas(qrcode.value, props.value, (error) => {
    if (error) {
      console.log(error)
    }
  })
}
</script>